package com.qf.java2102.qihaonan.hotel.dao.impl;

import com.qf.java2102.qihaonan.hotel.dao.IFoodTypeDao;
import com.qf.java2102.qihaonan.hotel.pojo.FoodType;
import com.qf.java2102.qihaonan.hotel.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @author qhn
 * @version 1.0
 */
public class FoodTypeDaoImpl implements IFoodTypeDao {

    private QueryRunner queryRunner = null;


    @Override
    public List<FoodType> findAll() throws SQLException {
        queryRunner = new QueryRunner(JdbcUtils.getDataSource());
        String sql = "SELECT `type_id` typeId,`type_name` typeName FROM `t_food_type`";
        return queryRunner.query(JdbcUtils.getConnection(), sql, new BeanListHandler<>(FoodType.class));
    }
}
